package com.aisile.manager.controller;
import com.aisile.entity.PageResult;
import com.aisile.entity.Result;
import com.aisile.pojo.TbSpecification;
import com.aisile.pojogroup.Specification;
import com.aisile.sellergoods.service.SpecificationService;
import com.alibaba.dubbo.config.annotation.Reference;
import com.sun.javafx.collections.MappingChange;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("specification")
public class SpecificationController {

    @Reference
    SpecificationService specificationService;
    @RequestMapping("findPage")
    public PageResult findPage(int page, int rows,@RequestBody TbSpecification tbSpecification){
        return specificationService.findPage(page,rows,tbSpecification);
    }
    @RequestMapping("findOne")
    public Specification findOne(Long id){
        return specificationService.findOne(id);
    }

    @RequestMapping("save")
    public Result save(@RequestBody Specification specification){
        try {
            specificationService.save(specification);
            return new Result(true,"");
        }catch (Exception e){
            return new Result(false,"服务器出现异常");
        }
    }
    @RequestMapping("update")
    public Result update(@RequestBody Specification specification){
        try {
            specificationService.update(specification);
            return new Result(true,"");
        }catch (Exception e){
            return new Result(false,"服务器出现异常");
        }
    }

    @RequestMapping("dele")
    public Result dele(Long[] ids){
        try {
            specificationService.dele(ids);
            return new Result(true,"");
        }catch (Exception e){
            return new Result(false,"服务器出现异常");
        }
    }
    @RequestMapping("findSpecList")
    public List<Map> findSpecList(){
        return specificationService.findSpecList();
    }
}
